#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
ll a[N];
int n,k,m;
ll c,d;
int check(ll x)
{
	vector<int> f(2*n+5,0);
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=x) cnt++;
	}

	for(int i=1;i<=n;i++)
	{
		if(a[i]>=x) continue;
		ll t=min(i-1,m-1);
		ll num=a[i]+c+d*t;
		if(num<x) continue;
	    f[max(m, i)]++;
	    if(a[i]+c>=x)
	    {
	    	f[min(n + 1, i + m)]--;
		}
		else
		{
			long long t = x - a[i] - c;
            int pos;
            if (t % d == 0) pos = t / d - 1;
            else pos = t / d;
            f[min(n + 1, i + m - pos - 1)]--;
		}
	}
	for(int i=1;i<=n;i++)
	{
		cnt+=f[i];

		if(cnt>=k) return 1;
	}
	return 0;
}
int main()
{
	cin>>n>>k>>m>>c>>d;

	for(int i=1;i<=n;i++) cin>>a[i];

	ll l=0,r=1e15;
	while(l<r)
	{
		ll mid=(l+r+1)/2ll;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	cout<<l;
	return 0;
}
